package com.tanhua.autoconfig.template;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
import com.aliyun.teaopenapi.models.Config;

/**
 * @author Hang
 */
public class SmsTemplate {

    public void sendSms(String mobile, String code) {
        String accessKeyId = "LTAI5tFzDeBUNya4GSNWLE1D";
        String accessKeySecret = "LPEbpkVU6KcCsVpjHR0KNoZhj7ilDv";

        try {
            Config config = new Config()
                    .setAccessKeyId(accessKeyId)
                    .setAccessKeySecret(accessKeySecret);
            config.endpoint="dysmsapi.aliyuncs.com";
            Client client = new Client(config);
            SendSmsRequest sendSmsRequest = new SendSmsRequest()
                    .setPhoneNumbers(mobile)
                    .setSignName("物流云商")
                    .setTemplateCode("SMS_205134115")
                    .setTemplateParam("{\"code\":\"" + code + "\"}");
            SendSmsResponse response = client.sendSms(sendSmsRequest);
            SendSmsResponseBody body = response.getBody();
        }catch (Exception e){
            e.printStackTrace();
        }


    }

}
